package zx.x.modules.yshbms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import zx.x.common.utils.PageUtils;
import zx.x.common.utils.Query;
import zx.x.modules.app.entity.UserEntity;
import zx.x.modules.yshbms.dao.User2Dao;
import zx.x.modules.yshbms.service.UserService;

import java.util.Map;


@Service("user2Service")
public class User2ServiceImpl extends ServiceImpl<User2Dao, UserEntity> implements UserService {
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<UserEntity> queryWrapper=new QueryWrapper<UserEntity>();
        if (params.get("name") != null) {
            queryWrapper.eq("name",params.get("name"));
        }
        if (params.get("mobile") != null) {
            queryWrapper.eq("mobile",params.get("mobile"));
        }
        if(params.get("authentication") != null){
            queryWrapper.eq("authentication",params.get("authentication"));
        }
        queryWrapper.orderByDesc("create_time");
        IPage<UserEntity> page = this.page(
                new Query<UserEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }
}